<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:ic="http://ivyteam.ch/jsf/component"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:pm="http://primefaces.org/mobile">

<cc:interface componentType="IvyComponent">
</cc:interface>

<cc:implementation>
	<cc:attribute name="sendCallBack"/>
		<p:fieldset legend="New Email">
			<h:form>
				<p:remoteCommand name="reset" process="@this" update="@form">
					<p:resetInput target="@form"></p:resetInput>
				</p:remoteCommand>
				<h:panelGrid columns="2" width="98%" style="height:auto">
					
					<p:outputLabel value="To" />
					<p:autoComplete id="dd" dropdown="true" value="#{data.reciever}" required="true" completeMethod="#{logic.autocompleteUser}" label="To"/>
					
					<p:outputLabel value="Subject" />
						<p:inputText required="true" style="width:99%" maxlength="1000" value="#{data.subject}" label="Subject"/>
					<p:outputLabel />
					
					<p:inputTextarea id="cont" rows="10" cols="83" value="#{data.content}" required="true" label="Content">
						<f:validateLength minimum="3" maximum="100" /> 
					</p:inputTextarea>
					
					
					<f:facet name="footer">
						<h:panelGroup style="display:block; text-align:right">
							<p:commandButton value="Close" onclick="PF('showComposer').hide()"/>
							<p:commandButton value="Save as draft" validateClient="true" actionListener="#{logic.draftMail}" update="@form" oncomplete="#{cc.attributes.sendCallBack}"/>
							<p:commandButton value="Send" validateClient="true" actionListener="#{logic.sendMail}" update="@form" oncomplete="#{cc.attributes.sendCallBack}"/>
						</h:panelGroup>
						<p:messages autoUpdate="true"/>
					</f:facet>
				</h:panelGrid>
			</h:form>
		</p:fieldset>
</cc:implementation>

</html>
